CAN Gateway code example  v1.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
cangw.hpp
Go to the documentation of this file.
1 /***********************************************************************************************//**
2  * @file cangw.hpp
3  * @brief Header file for cangw.cpp
4  * @date 2014-03-07
5  * @copyright Hatteland Display AS
6  **************************************************************************************************/
7 
8 //==================================================================================================
9 // Includes
10 //==================================================================================================
11 #include <hdj2534.h>
12 
13 //==================================================================================================
14 // Defines
15 //==================================================================================================
16 
17 
18 //==================================================================================================
19 // Typedefs
20 //==================================================================================================
21 /// Namespace for cangw module
22 namespace canGw
23 {
24  /// Definition of CAN Gateway's error codes
25  enum ErrCode_e
26  {
27  /// No error
29  /// An error occurred
31  };
32 
33  /// Definition of CAN Gateway channels' names
34  enum Channel_e
35  {
36  /// Name of CAN Gateway's channel 1
38  /// Name of CAN Gateway's channel 2
40  };
41 
42  /// Definition of CAN Gateway's baud rates
44  {
45  /// Baudrate 125 kbps
47  /// Baudrate 250 kbps
49  /// Baudrate 500 kbps
51  /// Baudrate 1 Mbps
53  };
54 
55  /// Definition of callback function for receive frames
56  typedef void (* RcvCb_t)(const J2534::PASSTHRU_MSG * rxPassThruMsg, unsigned long rxMsgNum);
57 }
58 
59 //==================================================================================================
60 // Exported variables
61 //==================================================================================================
62 
63 
64 //==================================================================================================
65 // Declarations of functions
66 //==================================================================================================
67 namespace canGw
68 {
69  ErrCode_e init(Baudrate_e baudChan1, Baudrate_e baudChan2, const RcvCb_t cbChan1,
70  const RcvCb_t cbChan2);
71  ErrCode_e uninit();
72  ErrCode_e send(Channel_e channel, J2534::PASSTHRU_MSG * txPassThruMsg);
73  ErrCode_e startPeriodic(Channel_e channel, J2534::PASSTHRU_MSG * txPassThruMsg,
74  unsigned long interval);
75 }
76 /**************************************************************************************************/
Baudrate 250 kbps.
Definition: cangw.hpp:48
Name of CAN Gateway's channel 2.
Definition: cangw.hpp:39
ErrCode_e startPeriodic(Channel_e channel, J2534::PASSTHRU_MSG *txPassThruMsg, unsigned long interval)
Function starts CAN Gateway's periodic message.
Definition: cangw.cpp:263
Baudrate 1 Mbps.
Definition: cangw.hpp:52
Name of CAN Gateway's channel 1.
Definition: cangw.hpp:37
Baudrate_e
Definition of CAN Gateway's baud rates.
Definition: cangw.hpp:43
ErrCode_e init(Baudrate_e baudChan1, Baudrate_e baudChan2, const RcvCb_t cbChan1, const RcvCb_t cbChan2)
Function initializes CAN Gateway device.
Definition: cangw.cpp:124
An error occurred.
Definition: cangw.hpp:30
Channel_e
Definition of CAN Gateway channels' names.
Definition: cangw.hpp:34
No error.
Definition: cangw.hpp:28
ErrCode_e
Definition of CAN Gateway's error codes.
Definition: cangw.hpp:25
Baudrate 125 kbps.
Definition: cangw.hpp:46
Baudrate 500 kbps.
Definition: cangw.hpp:50
void(* RcvCb_t)(const J2534::PASSTHRU_MSG *rxPassThruMsg, unsigned long rxMsgNum)
Definition of callback function for receive frames.
Definition: cangw.hpp:56
ErrCode_e send(Channel_e channel, J2534::PASSTHRU_MSG *txPassThruMsg)
Function sends PASSTHRU frame via given channel.
Definition: cangw.cpp:228
ErrCode_e uninit()
Function uninitializes CAN Gateway device.
Definition: cangw.cpp:201